package com.cxx.purchasecharge.core.model.persistence;

import java.util.Date;
import java.util.List;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;

import com.cxx.purchasecharge.core.model.BaseModel;
import com.cxx.purchasecharge.core.model.CustomerTypeCode;

/**
 * 客户
 */
@Entity
@Table (name = "pc_customer")
public class Customer extends BaseModel
{
    private static final long serialVersionUID = 1L;

    private long id;
    private String shortName;
    private CustomerTypeCode typeCode = CustomerTypeCode.CUSTOMER;
    private String companyName;
    private String companyIntroduction;
    /**
     * 公司地址或收货地址
     */
    private String address;
    private String zipCode;
    private String email;
    private String fax;
    /**
     * 公司固话
     */
    private String fixedPhone;

    private boolean deleted = false;
    /**
     * 人员规模
     */
    private String scale;
    /**
     * 意向产品
     */
    private String goodsIntention;
    /**
     * 公司法人
     */
    private String legalPerson;
    /**
     * 会员帐号
     */
    private String memberAccount;
    /**
     * 公司网址
     */
    private String webSite;
    /**
     * 公司注册日期
     */
    private Date registerDate;
    /**
     * 公司注册资金
     */
    private long registerFund;

    /**
     * 公司所在区域：如，湖南-永州-东安-白牙市镇
     */
    private String region;

    private String comment;

    private Date createDate;
    private Date lastUpdated;
    private long userSigned;
    private long userCreatedBy;
    private long userUpdatedBy;
    private boolean sharable = false;

    /**
     * 信用等级
     */
    private CustomerLevel customerLevel;

    private CustomerStatus customerStatus;
    /**
     * 经营行业
     */
    private CustomerTrade customerTrade;
    /**
     * 来源
     */
    private CustomerSource customerSource;

    private List <Contact> contacts;
    private List <Order> orders;
    private List <Payment> payments;
    private List <Receiver> receivers;
    /**
     * 欠款
     */
    private float dealMoney;

    public Customer ()
    {
    }

    public Customer (String shortName)
    {
        this.shortName = shortName;
    }

    @Id
    @GeneratedValue (strategy = GenerationType.AUTO)
    public long getId ()
    {
        return id;
    }

    public void setId (long id)
    {
        this.id = id;
    }

    @Column (nullable = false, unique = true)
    public String getShortName ()
    {
        return shortName;
    }

    public void setShortName (String shortName)
    {
        this.shortName = shortName;
    }

    public String getAddress ()
    {
        return address;
    }

    public void setAddress (String address)
    {
        this.address = address;
    }

    public String getEmail ()
    {
        return email;
    }

    public void setEmail (String email)
    {
        this.email = email;
    }

    @Column (length = 50)
    public String getFixedPhone ()
    {
        return fixedPhone;
    }

    public void setFixedPhone (String fixedPhone)
    {
        this.fixedPhone = fixedPhone;
    }

    public String getFax ()
    {
        return fax;
    }

    public void setFax (String fax)
    {
        this.fax = fax;
    }

    public String getScale ()
    {
        return scale;
    }

    public void setScale (String scale)
    {
        this.scale = scale;
    }

    public String getGoodsIntention ()
    {
        return goodsIntention;
    }

    public void setGoodsIntention (String goodsIntention)
    {
        this.goodsIntention = goodsIntention;
    }

    public String getLegalPerson ()
    {
        return legalPerson;
    }

    public void setLegalPerson (String legalPerson)
    {
        this.legalPerson = legalPerson;
    }

    public String getMemberAccount ()
    {
        return memberAccount;
    }

    public void setMemberAccount (String memberAccount)
    {
        this.memberAccount = memberAccount;
    }

    public Date getRegisterDate ()
    {
        return registerDate;
    }

    public void setRegisterDate (Date registerDate)
    {
        this.registerDate = registerDate;
    }

    public long getRegisterFund ()
    {
        return registerFund;
    }

    public void setRegisterFund (long registerFund)
    {
        this.registerFund = registerFund;
    }

    public String getRegion ()
    {
        return region;
    }

    public void setRegion (String region)
    {
        this.region = region;
    }

    public CustomerTypeCode getTypeCode ()
    {
        return typeCode;
    }

    public void setTypeCode (CustomerTypeCode typeCode)
    {
        this.typeCode = typeCode;
    }

    public String getCompanyName ()
    {
        return companyName;
    }

    public void setCompanyName (String companyName)
    {
        this.companyName = companyName;
    }

    @Column (length = 2048)
    public String getCompanyIntroduction ()
    {
        return companyIntroduction;
    }

    public void setCompanyIntroduction (String companyIntroduction)
    {
        this.companyIntroduction = companyIntroduction;
    }

    public String getZipCode ()
    {
        return zipCode;
    }

    public void setZipCode (String zipCode)
    {
        this.zipCode = zipCode;
    }

    public String getWebSite ()
    {
        return webSite;
    }

    public void setWebSite (String webSite)
    {
        this.webSite = webSite;
    }

    @Column (length = 1024)
    public String getComment ()
    {
        return comment;
    }

    public void setComment (String comment)
    {
        this.comment = comment;
    }

    public Date getCreateDate ()
    {
        return createDate;
    }

    public void setCreateDate (Date createDate)
    {
        this.createDate = createDate;
    }

    public Date getLastUpdated ()
    {
        return lastUpdated;
    }

    public void setLastUpdated (Date lastUpdated)
    {
        this.lastUpdated = lastUpdated;
    }

    public long getUserSigned ()
    {
        return userSigned;
    }

    public void setUserSigned (long userSigned)
    {
        this.userSigned = userSigned;
    }

    public long getUserCreatedBy()
    {
        return userCreatedBy;
    }

    public void setUserCreatedBy(long userCreatedBy)
    {
        this.userCreatedBy = userCreatedBy;
    }

    public long getUserUpdatedBy()
    {
        return userUpdatedBy;
    }

    public void setUserUpdatedBy(long userUpdatedBy)
    {
        this.userUpdatedBy = userUpdatedBy;
    }

    public boolean isDeleted ()
    {
        return deleted;
    }

    public void setDeleted (boolean deleted)
    {
        this.deleted = deleted;
    }

    public boolean isSharable ()
    {
        return sharable;
    }

    public void setSharable (boolean sharable)
    {
        this.sharable = sharable;
    }

    @ManyToOne
    @JoinColumn (name = "customer_level_id")
    public CustomerLevel getCustomerLevel ()
    {
        return customerLevel;
    }

    public void setCustomerLevel (CustomerLevel customerLevel)
    {
        this.customerLevel = customerLevel;
    }

    @ManyToOne
    @JoinColumn (name = "customer_status_id")
    public CustomerStatus getCustomerStatus ()
    {
        return this.customerStatus;
    }

    public void setCustomerStatus (CustomerStatus customerStatus)
    {
        this.customerStatus = customerStatus;
    }

    @ManyToOne
    @JoinColumn (name = "customer_trade_id")
    public CustomerTrade getCustomerTrade ()
    {
        return customerTrade;
    }

    public void setCustomerTrade (CustomerTrade customerTrade)
    {
        this.customerTrade = customerTrade;
    }

    @ManyToOne
    @JoinColumn (name = "customer_source_id")
    public CustomerSource getCustomerSource ()
    {
        return customerSource;
    }

    public void setCustomerSource (CustomerSource customerSource)
    {
        this.customerSource = customerSource;
    }

    @OneToMany (mappedBy = "customer")
    public List <Contact> getContacts ()
    {
        return contacts;
    }

    public void setContacts (List <Contact> contacts)
    {
        this.contacts = contacts;
    }

    @OneToMany (mappedBy = "customer")
    public List <Order> getOrders ()
    {
        return orders;
    }

    public void setOrders (List <Order> orders)
    {
        this.orders = orders;
    }

    @OneToMany (mappedBy = "customer", cascade = CascadeType.ALL)
    public List <Payment> getPayments ()
    {
        return payments;
    }

    public void setPayments (List <Payment> payments)
    {
        this.payments = payments;
    }

    @OneToMany (mappedBy = "customer", cascade = CascadeType.ALL)
    public List <Receiver> getReceivers ()
    {
        return receivers;
    }

    public void setReceivers (List <Receiver> receivers)
    {
        this.receivers = receivers;
    }

    public float getDealMoney ()
    {
        return dealMoney;
    }

    public void setDealMoney (float dealMoney)
    {
        this.dealMoney = dealMoney;
    }

}
